# Maintainer: Muflone http://www.muflone.com/contacts/english/
# Contributor: jsteel <mail at jsteel dot org>
# Contributor: Daniel YC Lin <dlin.tw at gmail>
# Contributor: Tdy  <tdy@gmx.com>
# Contributor: Biginoz <biginoz at free.fr>
# Contributor: Archan Paul <paul.archan@gmail.com>

pkgname=sweethome3d
pkgver=7.1
pkgrel=2
pkgdesc="An interior design application to draw the plan of your house in a 3D environment"
arch=('loong64' 'x86_64')
url="http://www.sweethome3d.com/"
license=('GPL' 'custom')
depends=('java-runtime<17' 'shared-mime-info' 'desktop-file-utils' 'libxext' 'libgl' 'libxrender' 'libnsl')
makedepends=('ant' 'strip-nondeterminism')
source=("SweetHome3D-${pkgver}-src.zip"::"https://downloads.sourceforge.net/${pkgname}/SweetHome3D-${pkgver}-src.zip"
        "${pkgname}.sh"
        "${pkgname}.desktop"
        "${pkgname}.xml")
sha256sums=('04b7453410ec918971cf69aeb5d0a8d1284369ffe544f8d49e8b81d2bd39b2a2'
            '1e037cbb981dbd5d686a5b85cae43656193c3fcb543a1b46f93ef739551dcd65'
            '5eea3337d956d773b05ddef69fe9d34b940ff550370dc92bf307f1b9a3957f9e'
            'ec0ad1a0671f708af68ced46bec1f4ab377e24ca1a0a9984867ee5fe484f57c5')
install="${pkgname}.install"

build() {
  cd "SweetHome3D-${pkgver}-src"
  ant application textures furniture examples help java3dLibraries
  # FS#70332 ( https://bugs.archlinux.org/task/70332 )
  find "${srcdir}" -type f -name '*.jar' -exec strip-nondeterminism {} +
}

package() {
  # Desktop and launchers
  install -m 755 -D "${pkgname}.sh" "${pkgdir}/usr/bin/${pkgname}"
  install -m 755 -D "${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop"
  install -m 644 -D "${pkgname}.xml" "${pkgdir}/usr/share/mime/packages/${pkgname}.xml"
  # Install licenses
  cd "SweetHome3D-${pkgver}-src"
  install -m 755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
  install -m 755 -t "${pkgdir}/usr/share/licenses/${pkgname}" THIRDPARTY-LICENSE-*
  # Install icon
  install -m 644 -D "deploy/SweetHome3DIcon48x48.png" "${pkgdir}/usr/share/pixmaps/${pkgname}.png"
  # Install main program and libraries
  install -m 755 -d "${pkgdir}/usr/share/java/${pkgname}"
  install -m 644 -t "${pkgdir}/usr/share/java/${pkgname}" build/*.jar
  install -m 644 -t "${pkgdir}/usr/share/java/${pkgname}" libtest/jnlp.jar
  cd "lib"
  install -m 644 -t "${pkgdir}/usr/share/java/${pkgname}" *.jar
  # Java3D 1.5 libraries
  install -m 755 -d "${pkgdir}/usr/lib/${pkgname}/java3d-1.5"
  mv -t "${pkgdir}/usr/lib/${pkgname}/java3d-1.5" \
    "${pkgdir}"/usr/share/java/${pkgname}/{j3dcore.jar,j3dutils.jar,vecmath.jar}
  install -m 755 -t "${pkgdir}/usr/lib/${pkgname}/java3d-1.5" linux/x64/libj3dcore-ogl.so
  # Java3D 1.6 libraries
  install -m 755 -d "${pkgdir}/usr/lib/${pkgname}/java3d-1.6"
  install -m 644 -t "${pkgdir}/usr/lib/${pkgname}/java3d-1.6" java3d-1.6/*.jar
  install -m 755 -t "${pkgdir}/usr/lib/${pkgname}/java3d-1.6" java3d-1.6/linux/amd64/*.so
}
